PREF_COMMIT

The PREF_SET procedure is used to set new values for IDL preferences. However, a preference value set in this way does not immediately take effect. Rather, it is put into a pending state, in which IDL remembers the change, but does not use it. To make a pending preference value take effect, IDL must commit it. To commit a preference, IDL takes the following steps:

  1. Writes a new user preference file that merges the new changes with the previously specified preference values.
  2. Updates its internal state to make the pending values current.
  3. Notifies the various parts of IDL that depend on the altered preference so that they can adapt to the change.

There are two ways to commit a preference:

The pending state is useful for applications that let a user manipulate preferences. In such an application, the user can make changes, but those changes can be discarded without taking effect if the user clicks the Cancel button. PREF_SET can be used to make the user’s changes. If the user clicks Done to confirm the changes, PREF_COMMIT is used to make them permanent. Otherwise, they are discarded by using the RESET keyword. The pending state lifts the burden of tracking user changes from the high-level application and greatly simplifies its implementation.

For more information on IDL’s preferences, see About IDL System Preferences.

Note: Authors of IDL applications should not use this routine in their code to make preference changes. See About IDL System Preferences for more information.

Examples

To commit all preferences with pending values:

PREF_COMMIT

To commit only the IDL_PATH preference (which supplies the value of the !PATH system variable), while leaving all other preferences in their current state:

PREF_COMMIT, 'IDL_PATH'

To discard the currently pending value for IDL_PATH:

PREF_COMMIT, /RESET, 'IDL_PATH'

To restore the !PATH system variable to the value given by the IDL_PATH preference (without discarding the pending value, if any):

PREF_COMMIT, /RESIGNAL, 'IDL_PATH'

Syntax

PREF_COMMIT [, PreferenceName] [, /RESET] [, /RESIGNAL]

Arguments

PreferenceName

A string scalar or array that supplies the names of the preferences to commit. If no arguments are supplied, all preferences currently in the pending state are committed. Any specified preferences that are not in the pending state are quietly ignored.

Keywords

RESET

Set this keyword to have PREF_COMMIT discard the pending values, if any, for the specified preferences. The preferences leave the pending state and retain their previous value.

RESIGNAL

Set this keyword to have PREF_COMMIT not check or alter the pending state of the specified preferences. Instead, the procedure behaves as if the current value of the preference had just been committed and signals the part of IDL that uses that preference to reset itself.

Version History

6.2

Introduced

See Also

PREF_GET, PREF_SET, About IDL System Preferences